<?php

namespace App\Service\Jwt;

use App\Models\User;
use Carbon\Carbon;

class TokenService
{

    /**
     * 签发token
     * @param $user
     * @param array $scopes
     * @return string
     */
    public function createToken($user, array $scopes=[]): string
    {
        if ($user instanceof User) $tokenName = 'api';
        else $tokenName = 'admin';
        $token = $user->createToken($tokenName, $scopes);
        return $token->accessToken;
    }
}
